﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.Master" AutoEventWireup="true"
	CodeBehind="ExportInfo.aspx.cs" Inherits="SaleManagement.Web.Pages.ExportInfo"
	Title="" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
	Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
	Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
	Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
	Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
	<div id="divContent" runat="server">
		<table width="100%">
			<tr>
				<td class="search_header">
					Thông tin hóa đơn chuyển kho
				</td>
			</tr>
			<tr>
				<td style="text-align: right">
					<dxe:ASPxHyperLink ID="hlBack" runat="server" Text="Trở về" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
						CssPostfix="Aqua" Cursor="pointer">
						<ClientSideEvents Click="function(s, e) {
	onBack();
}" />
					</dxe:ASPxHyperLink>
				</td>
			</tr>
			<tr>
				<td class="insert_header">
					Thông tin chung
				</td>
			</tr>
			<tr>
				<td class="formInfo">
					<table border="0" width="100%" style="padding-bottom: 20px">
						<tr>
							<td style="width: 100px">
								Mã hóa đơn:
							</td>
							<td style="width: 170px">
								<dxe:ASPxTextBox ID="txtRefNo" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
									CssPostfix="Aqua" Width="170px" ClientEnabled="False" ClientInstanceName="txtRefNo">
									<ValidationSettings>
										<ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
										<ErrorFrameStyle ImageSpacing="4px">
											<ErrorTextPaddings PaddingLeft="4px" />
										</ErrorFrameStyle>
									</ValidationSettings>
								</dxe:ASPxTextBox>
							</td>
							<td style="width: 50px">
							</td>
							<td style="width: 100px">
								Ngày chuyển kho:
							</td>
							<td style="width: 170px">
								<dxe:ASPxDateEdit ID="deExportDate" ClientInstanceName="deExportDate" runat="server"
									CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" ImageFolder="~/App_Themes/Aqua/{0}/"
									ShowShadow="False" Width="170px">
									<ValidationSettings>
										<ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" Width="14px" />
										<ErrorFrameStyle ImageSpacing="4px">
											<ErrorTextPaddings PaddingLeft="4px" />
										</ErrorFrameStyle>
									</ValidationSettings>
									<DropDownButton>
										<Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
											UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png"
											Width="9px" />
									</DropDownButton>
									<CalendarProperties>
										<HeaderStyle Spacing="1px" />
										<FooterStyle Spacing="17px" />
									</CalendarProperties>
								</dxe:ASPxDateEdit>
							</td>
							<td class="notNullNote">
								(*)
							</td>
						</tr>
						<tr>
							<td>
								Kho xuất:
							</td>
							<td>
								<dxe:ASPxComboBox ID="cbxFromRepository" ClientInstanceName="cbxFromRepository" runat="server"
									CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" ImageFolder="~/App_Themes/Aqua/{0}/"
									LoadingPanelText="" ShowShadow="False" ValueType="System.Int32" TextField="Name"
									ValueField="Id">
									<ButtonEditEllipsisImage Height="3px" Url="~/App_Themes/Aqua/Editors/edtEllipsis.png"
										UrlDisabled="~/App_Themes/Aqua/Editors/edtEllipsisDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtEllipsisHottracked.png"
										UrlPressed="~/App_Themes/Aqua/Editors/edtEllipsisPressed.png" Width="12px" />
									<DropDownButton>
										<Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
											UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownPressed.png"
											Width="9px" />
									</DropDownButton>
									<ValidationSettings>
										<ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" Width="14px" />
										<ErrorFrameStyle ImageSpacing="4px">
											<ErrorTextPaddings PaddingLeft="4px" />
										</ErrorFrameStyle>
									</ValidationSettings>
								</dxe:ASPxComboBox>
							</td>
							<td class="notNullNote">
								(*)
							</td>
							<td>
								Kho nhập:
							</td>
							<td>
								<dxe:ASPxComboBox ID="cbxToRepository" ClientInstanceName="cbxToRepository" runat="server"
									CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" ImageFolder="~/App_Themes/Aqua/{0}/"
									LoadingPanelText="" ShowShadow="False" ValueType="System.Int32" TextField="Name"
									ValueField="Id">
									<ButtonEditEllipsisImage Height="3px" Url="~/App_Themes/Aqua/Editors/edtEllipsis.png"
										UrlDisabled="~/App_Themes/Aqua/Editors/edtEllipsisDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtEllipsisHottracked.png"
										UrlPressed="~/App_Themes/Aqua/Editors/edtEllipsisPressed.png" Width="12px" />
									<DropDownButton>
										<Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
											UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownPressed.png"
											Width="9px" />
									</DropDownButton>
									<ValidationSettings>
										<ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" Width="14px" />
										<ErrorFrameStyle ImageSpacing="4px">
											<ErrorTextPaddings PaddingLeft="4px" />
										</ErrorFrameStyle>
									</ValidationSettings>
								</dxe:ASPxComboBox>
							</td>
							<td class="notNullNote">
								(*)
							</td>
						</tr>
						<tr>
							<td>
								Tổng tiền:
							</td>
							<td>
								<dxe:ASPxTextBox ID="txtTotalAmount" ClientInstanceName="txtTotalAmount" runat="server"
									CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" Width="170px">
									<ValidationSettings Display="Dynamic">
										<ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
										<ErrorFrameStyle ImageSpacing="4px">
											<ErrorTextPaddings PaddingLeft="4px" />
										</ErrorFrameStyle>
									</ValidationSettings>
									<MaskSettings IncludeLiterals="None" Mask="&lt;0..9999999999999999999g&gt;" />
								</dxe:ASPxTextBox>
							</td>
							<td class="notNullNote">
								(*)
							</td>
						</tr>
						<tr>
							<td>
								Ghi chú:
							</td>
							<td colspan="5">
								<dxe:ASPxMemo ID="mmNote" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
									CssPostfix="Aqua" Height="71px" Width="495px">
									<ValidationSettings>
										<ErrorImage Url="~/App_Themes/Aqua/Editors/edtError.png" />
										<ErrorFrameStyle ImageSpacing="4px">
											<ErrorTextPaddings PaddingLeft="4px" />
										</ErrorFrameStyle>
									</ValidationSettings>
								</dxe:ASPxMemo>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td class="insert_header" style="height: 24px">
					Thông tin chi tiết
				</td>
			</tr>
			<tr>
				<td class="formInfo">
					<table width="100%">
						<tr>
							<td>
								<dxwgv:ASPxGridView ID="gvExportDetail" ClientInstanceName="gvExportDetail" KeyFieldName="Id"
									runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua"
									Width="100%" EnableCallbackCompression="True" AutoGenerateColumns="False" OnCustomCallback="gvExportDetail_CustomCallback"
									OnCustomJSProperties="gvExportDetail_CustomJSProperties" OnPageIndexChanged="gvExportDetail_PageIndexChanged">
									<Styles CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua">
									</Styles>
									<SettingsBehavior AllowDragDrop="False" AllowGroup="False" AllowSort="False" ConfirmDelete="True" />
									<SettingsPager PageSize="20">
										<AllButton>
											<Image Height="19px" Width="27px" />
										</AllButton>
										<FirstPageButton>
											<Image Height="19px" Width="23px" />
										</FirstPageButton>
										<LastPageButton>
											<Image Height="19px" Width="23px" />
										</LastPageButton>
										<NextPageButton>
											<Image Height="19px" Width="19px" />
										</NextPageButton>
										<PrevPageButton>
											<Image Height="19px" Width="19px" />
										</PrevPageButton>
									</SettingsPager>
									<Images ImageFolder="~/App_Themes/Aqua/{0}/">
										<HeaderSortDown Height="5px" Url="~/App_Themes/Aqua/GridView/gvHeaderSortDown.png"
											Width="7px" />
										<ExpandedButton Height="15px" Url="~/App_Themes/Aqua/GridView/gvExpandedButton.png"
											Width="15px" />
										<CollapsedButton Height="15px" Url="~/App_Themes/Aqua/GridView/gvCollapsedButton.png"
											Width="15px" />
										<HeaderFilter Height="19px" Url="~/App_Themes/Aqua/GridView/gvHeaderFilter.png" Width="19px" />
										<DetailCollapsedButton Height="15px" Url="~/App_Themes/Aqua/GridView/gvDetailCollapsedButton.png"
											Width="15px" />
										<DetailExpandedButton Height="15px" Url="~/App_Themes/Aqua/GridView/gvDetailExpandedButton.png"
											Width="15px" />
										<HeaderActiveFilter Height="19px" Url="~/App_Themes/Aqua/GridView/gvHeaderFilterActive.png"
											Width="19px" />
										<HeaderSortUp Height="5px" Url="~/App_Themes/Aqua/GridView/gvHeaderSortUp.png" Width="7px" />
										<FilterRowButton Height="13px" Width="13px" />
										<WindowResizer Height="13px" Url="~/App_Themes/Aqua/GridView/WindowResizer.png" Width="13px" />
									</Images>
									<SettingsLoadingPanel Mode="Disabled" />
									<StylesEditors>
										<ProgressBar Height="25px">
										</ProgressBar>
									</StylesEditors>
									<ImagesEditors>
										<CalendarFastNavPrevYear Height="19px" Url="~/App_Themes/Aqua/Editors/edtCalendarFNPrevYear.png"
											Width="19px" />
										<SpinEditLargeIncrement Height="9px" Url="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncImage.png"
											UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncHottrackedImage.png"
											UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncHottrackedImage.png" Width="7px" />
										<SpinEditLargeDecrement Height="9px" Url="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecImage.png"
											UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecHottrackedImage.png"
											UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecHottrackedImage.png" Width="7px" />
										<SpinEditIncrement Height="6px" Url="~/App_Themes/Aqua/Editors/edtSpinEditIncrementImage.png"
											UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditIncrementDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditIncrementHottrackedImage.png"
											UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditIncrementHottrackedImage.png"
											Width="7px" />
										<SpinEditDecrement Height="7px" Url="~/App_Themes/Aqua/Editors/edtSpinEditDecrementImage.png"
											UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditDecrementDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditDecrementHottrackedImage.png"
											UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditDecrementHottrackedImage.png"
											Width="7px" />
										<CalendarFastNavNextYear Height="19px" Url="~/App_Themes/Aqua/Editors/edtCalendarFNNextYear.png"
											Width="19px" />
										<DropDownEditDropDown Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png"
											UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png"
											Width="9px" />
									</ImagesEditors>
									<Columns>
										<dxwgv:GridViewDataColumn VisibleIndex="0" Caption="Tác vụ" Width="100px">
											<DataItemTemplate>
												<img alt="Cập nhật" title="Cập nhật" src="../Images/edit.png" style="cursor: pointer"
													onclick="fillExportDetail('<%#Eval("Id") %>', '<%#Eval("ProductGroupId") %>', '<%#Eval("ProductId") %>', '<%#Eval("Quantity") %>');" />
												<img alt="Xóa" title="Xóa" src="../Images/delete.png" style="cursor: pointer" onclick="deleteExportDetail('<%#Eval("Id") %>');" />
											</DataItemTemplate>
											<HeaderStyle HorizontalAlign="Center" />
											<CellStyle HorizontalAlign="Center" />
										</dxwgv:GridViewDataColumn>
										<dxwgv:GridViewDataTextColumn Caption="Nhóm sản phẩm" VisibleIndex="1" FieldName="ProductGroupName">
											<HeaderStyle HorizontalAlign="Center" />
										</dxwgv:GridViewDataTextColumn>
										<dxwgv:GridViewDataTextColumn VisibleIndex="2" FieldName="ProductGroupId" Visible="False">
										</dxwgv:GridViewDataTextColumn>
										<dxwgv:GridViewDataTextColumn Caption="Tên sản phẩm" VisibleIndex="2" FieldName="ProductName">
											<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
										</dxwgv:GridViewDataTextColumn>
										<dxwgv:GridViewDataTextColumn FieldName="ProductId" Visible="False" VisibleIndex="3">
										</dxwgv:GridViewDataTextColumn>
										<dxwgv:GridViewDataTextColumn Caption="Số lượng" VisibleIndex="3" FieldName="Quantity">
											<HeaderStyle HorizontalAlign="Center" />
										</dxwgv:GridViewDataTextColumn>
									</Columns>
									<ClientSideEvents EndCallback="function(s, e){gvExportDetail_EndCallback(s, e);}" />
								</dxwgv:ASPxGridView>
							</td>
						</tr>
						<tr>
							<td>
								<dxe:ASPxButton ID="btnNew" runat="server" Text="Thêm mới" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
									CssPostfix="Aqua" AutoPostBack="False">
									<Image Url="~/Images/add.png" />
									<ClientSideEvents Click="function(s, e) { addNewDetail();}" />
								</dxe:ASPxButton>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td align="center">
					<dxe:ASPxButton ID="ASPxButton1" runat="server" Text="Lưu" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
						CssPostfix="Aqua" AutoPostBack="False">
						<Image Url="~/Images/save.png" />
						<ClientSideEvents Click="function(s, e) { onBtnSaveClick(s, e);}" />
					</dxe:ASPxButton>
				</td>
			</tr>
		</table>
		<dxpc:ASPxPopupControl ID="pcExportDetail" runat="server" ClientInstanceName="pcExportDetail"
			CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" HeaderText="Thông tin chi tiết hóa đơn"
			ImageFolder="~/App_Themes/Aqua/{0}/" Modal="True" PopupHorizontalAlign="WindowCenter"
			PopupVerticalAlign="WindowCenter">
			<ContentStyle VerticalAlign="Top">
			</ContentStyle>
			<SizeGripImage Height="12px" />
			<ContentCollection>
				<dxpc:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
					<table width="300px" border="0">
						<tr>
							<td>
								Nhóm sản phẩm:
							</td>
							<td>
								<dxe:ASPxComboBox ID="cbxProductGroup" runat="server" ClientInstanceName="cbxProductGroup"
									CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" ImageFolder="~/App_Themes/Aqua/{0}/"
									LoadingPanelText="" ShowShadow="False" ValueType="System.Int32" TextField="Name"
									ValueField="Id">
									<DropDownButton>
										<Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
											UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownPressed.png"
											Width="9px" />
									</DropDownButton>
									<ButtonEditEllipsisImage Height="3px" Url="~/App_Themes/Aqua/Editors/edtEllipsis.png"
										UrlDisabled="~/App_Themes/Aqua/Editors/edtEllipsisDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtEllipsisHottracked.png"
										UrlPressed="~/App_Themes/Aqua/Editors/edtEllipsisPressed.png" Width="12px" />
									<ValidationSettings>
										<ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" Width="14px" />
										<ErrorFrameStyle ImageSpacing="4px">
											<ErrorTextPaddings PaddingLeft="4px" />
										</ErrorFrameStyle>
									</ValidationSettings>
									<ClientSideEvents ValueChanged="function(s,e){cbxProductGroup_ValueChanged('');}" />
								</dxe:ASPxComboBox>
							</td>
							<td class="notNullNote">
								(*)
							</td>
						</tr>
						<tr>
							<td>
								Sản phẩm:
							</td>
							<td>
								<dxe:ASPxComboBox ID="cbxProduct" runat="server" ClientInstanceName="cbxProduct"
									CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" ImageFolder="~/App_Themes/Aqua/{0}/"
									LoadingPanelText="" ShowShadow="False" ValueType="System.Int32" OnCallback="cbxProduct_Callback"
									TextField="Name" ValueField="Id">
									<DropDownButton>
										<Image Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png" UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png"
											UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" UrlPressed="~/App_Themes/Aqua/Editors/edtDropDownPressed.png"
											Width="9px" />
									</DropDownButton>
									<ButtonEditEllipsisImage Height="3px" Url="~/App_Themes/Aqua/Editors/edtEllipsis.png"
										UrlDisabled="~/App_Themes/Aqua/Editors/edtEllipsisDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtEllipsisHottracked.png"
										UrlPressed="~/App_Themes/Aqua/Editors/edtEllipsisPressed.png" Width="12px" />
									<ValidationSettings>
										<ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" Width="14px" />
										<ErrorFrameStyle ImageSpacing="4px">
											<ErrorTextPaddings PaddingLeft="4px" />
										</ErrorFrameStyle>
									</ValidationSettings>
									<ClientSideEvents EndCallback="function(s, e){cbxProduct_EndCallback();}" />
								</dxe:ASPxComboBox>
							</td>
							<td class="notNullNote">
								(*)
							</td>
						</tr>
						<tr>
							<td>
								Số lượng:
							</td>
							<td>
								<dxe:ASPxTextBox ID="txtQuantity" runat="server" ClientInstanceName="txtQuantity"
									CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" Width="170px">
									<MaskSettings IncludeLiterals="None" Mask="&lt;0..9999999999999999999g&gt;" />
									<ValidationSettings Display="Dynamic">
										<ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
										<ErrorFrameStyle ImageSpacing="4px">
											<ErrorTextPaddings PaddingLeft="4px" />
										</ErrorFrameStyle>
									</ValidationSettings>
								</dxe:ASPxTextBox>
							</td>
							<td class="notNullNote">
								(*)
							</td>
						</tr>
						<tr>
							<td colspan="3" align="center" style="padding-top: 10px">
								<table>
									<tr>
										<td>
											<dxe:ASPxButton ID="btnDetailSave" runat="server" Text="Lưu" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
												CssPostfix="Aqua" AutoPostBack="False">
												<Image Url="~/Images/save.png" />
												<ClientSideEvents Click="function(s, e) { onBtnDetailSaveClick();}" />
											</dxe:ASPxButton>
										</td>
										<td>
											<dxe:ASPxButton ID="btnDetailCancel" runat="server" Text="Hủy" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
												CssPostfix="Aqua" AutoPostBack="False">
												<Image Url="~/Images/undo.gif" />
												<ClientSideEvents Click="function(s, e) { pcExportDetail.Hide();}" />
											</dxe:ASPxButton>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</dxpc:PopupControlContentControl>
			</ContentCollection>
			<CloseButtonImage Height="16px" />
			<HeaderStyle Font-Bold="True" ForeColor="#59A1EF" />
		</dxpc:ASPxPopupControl>
	</div>
	<asp:HiddenField ID="hfExportId" runat="server" />
	<asp:HiddenField ID="hfDetailId" runat="server" />

	<script type="text/javascript" language="javascript">
    var editedProductId = null;
    
    function onBack() {
      window.location.href = "ExportList.aspx";
    }

    function addNewDetail()
    {
      fillExportDetail(null, null, null, 0);
    }

    function fillExportDetail(id, productGroupId, productId, quantity)
    {
      document.getElementById('<%=hfDetailId.ClientID %>').value = id;
      cbxProductGroup.SetValue(productGroupId);
      editedProductId = productId;
      cbxProductGroup_ValueChanged();
      txtQuantity.SetValue(quantity);
      
      pcExportDetail.Show();
    }
    
    function deleteExportDetail(id)
    {
      if (confirm('Bạn có thật sự muốn xóa không?'))
      {
        pcWaiting.Show();
        gvExportDetail.PerformCallback('DeleteDetail|' + id);
      }
    }

    function cbxProductGroup_ValueChanged()
    {
      cbxProduct.ClearItems();
      cbxProduct.PerformCallback('Load');
    }
    
    function cbxProduct_EndCallback()
    {
      cbxProduct.SetValue(editedProductId);
    }
    
    function checkExportPara()
    {
      if (deExportDate.GetValue() == null)
      {
        alert('Vui lòng nhập ngày xuất hàng.');
        return false;
      }
      
      if (cbxFromRepository.GetValue() == null)
      {
        alert('Vui lòng nhập kho xuất hàng.');
        return false;
      }
      
      if (cbxToRepository.GetValue() == null)
      {
        alert('Vui lòng nhập kho nhập hàng.');
        return false;
      }
      
      return true;
    }
    
    function checkDetailPara()
    {
      if (cbxProductGroup.GetValue() == null)
      {
        alert('Vui lòng nhập nhóm sản phẩm.');
        return false;
      }
      
      if (cbxProduct.GetValue() == null)
      {
        alert('Vui lòng nhập sản phẩm.');
        return false;
      }
      
      if (txtQuantity.GetValue() <= 0)
      {
        alert('Số lượng sản phẩm phải lớn hơn 0.');
        return false;
      }
      
      return true;
    }
    
    function onBtnDetailSaveClick()
    {
      if (checkDetailPara())
      {
        pcWaiting.Show();
        gvExportDetail.PerformCallback('SaveDetail');
      }
    }
    
    function onBtnSaveClick(s, e) {
      if (checkExportPara())
      {
        pcWaiting.Show();
        gvExportDetail.PerformCallback('Save');
      }
    }
    
    function gvExportDetail_EndCallback(s, e)
    {
      pcWaiting.Hide();
      var error = gvExportDetail.cpInnerError.split('|');
      switch(error[0])
      {
        case 'DeleteDetail':
          break;
        case 'SaveDetail':
          pcExportDetail.Hide();   
          break;
        case 'Save':
          document.getElementById('<%=hfExportId.ClientID %>').value = error[1];
          txtRefNo.SetText(error[2]);
          alert('Dữ liệu đã được cập nhật thành công.');
          break;
        default:
          alert(error[0]);
          break;
      }
    }
	</script>

</asp:Content>
